<script>
layui.config({
	base:'#(ctx)/manage/_assets/libs/layui/extends/'
}).extend({
	treeSelect:'treeSelect'
}).use(['jquery', 'form', 'layedit', 'treeSelect'], function(){
	var $ = layui.jquery, form = layui.form, layedit = layui.layedit, treeSelect = layui.treeSelect;
	### 初始化下拉选择器
	treeSelect.render({
		elem: '#goodsCategorySelect',	### css选择器，推荐使用id
		data: '#(ctx)/manage/goodsCategory/ajaxGetGoodsCategoryTree', ### 请求地址
		type: 'post', ### ajax请求方式：post/get
		key: {
			id: 'id', ### 返回数据中主键的属性名称，默认值为id
		},
		click: function (data) { ### 节点点击回调函数
		},
		style: {
			folder: {
				enable: false
			},
			line: {
				enable: true
			}
		},
		### 加载完成后的回调函数
        success: function (d) {
        	treeSelect.checkNode('goodsCategorySelect', #(goodsCategory.parentId));
        	treeSelect.refresh('goodsCategorySelect');
        }
	});

	### 自定义验证规则
	form.verify({
		name : function(value, item) {
			if (value.length < 2 || value.length > 50) {
				return '名称必须2到50位字符';
			}
		}
	});
});
</script>